﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDPComm{

    public class UDPClient
    {

        private static IPAddress GroupAddress = IPAddress.Parse("192.168.0.255");

        private static int GroupPort = 8089;

        public void Send(String message)
        {
            UdpClient sender = new UdpClient();

            IPEndPoint groupEP = new IPEndPoint(GroupAddress, GroupPort);

            try
            {
                Console.WriteLine("Sending datagram : {0}", message);

                byte[] bytes = Encoding.ASCII.GetBytes(message);

                sender.Send(bytes, bytes.Length, groupEP);

                sender.Close();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

        }

    }
}